<template>
	<view>
		<view class="guess-section">
			<view v-for="(item, index) in guess" :key="index" class="guess-item" @click="navToDetailPage(item,2)">
				<view class="image-wrapper">
					<image class="guess-image" :src="item.img||`../../static/errorImage.jpg`" mode="aspectFit">
					</image>
				</view>
				<text class="title clamp" >{{item.title}}</text>
				<text class="price">￥{{item.price}}</text>
				<shopping-cart class="shoppingCart" :class="cartId==3?'cart-btn':''" :Item="item" :cartId="cartId"
					color="#e15852"></shopping-cart>
			</view>
		</view>
	</view>
</template>

<script>
	import Product from '@/components/product/product1.vue';
	import shoppingCart from '@/components/shoppingCart-Button.vue';
	export default {
		components: {
			Product,
			shoppingCart
		},
		name: 'recommList',
		props: {
			//列表
			guess: {
				type: Array,
				default: () => []
			},
			//标题
			title: {
				type: String,
				default: '猜你喜欢'
			}
		},
		data() {
			return {
				cartId: 1,
			};
		},
		watch: {},
		methods: {
			//详情页
			navToDetailPage(item, typeID) {
				console.log(item);
				let id = '0',
					acytpe = '',
					goodsid = item.id || item.FItemID;
				uni.navigateTo({
					url: `/pages/product/product?id=${id}&actype=${acytpe}&goodsid=${goodsid}`
				})
			},
		}
	}
</script>

<style lang="scss">
	.shoppingCart {
		width: auto;
		height: auto;
		position: absolute;
		bottom: 25upx;
		right: 10upx;
	}

	.cart-btn {
		bottom: 35upx;
	}

	/* 猜你喜欢 */
	.guess-section {
		display: flex;
		flex-wrap: wrap;
		padding: 0 30upx;
		background: #fff;
		width: 100%;
		position: absolute;

		.guess-item {
			display: flex;
			flex-direction: column;
			width: 48%;
			padding-bottom: 40upx;
			position: relative;

			&:nth-child(2n+1) {
				margin-right: 4%;
			}
		}

		.image-wrapper {
			width: 100%;
			height: 330upx;
			border-radius: 6upx;
			overflow: hidden;

			.guess-image {
				width: 100%;
				height: 100%;
				opacity: 1;
			}
		}

		.title {
			font-size: $font-lg;
			color: $font-color-dark;
			line-height: 80upx;
		}

		.price {
			font-size: $font-lg;
			color: $uni-color-primary;
			line-height: 1;
		}
	}
</style>
